package File2;

import java.io.*;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 86136
 * Date: 2025-04-28
 * Time: 19:48
 */
public class Demo2 {
    public static void main(String[] args) {
//        InputStream inputStream = null;
//        try {
//           inputStream = new FileInputStream("./test.txt");
//        } catch (FileNotFoundException e) {
//            e.printStackTrace();
//        }finally {
//            try {
//                inputStream.close();
//            } catch (IOException e) {
//                e.printStackTrace();
//            }
//        }

        try(InputStream inputStream = new FileInputStream("./test.txt")) {
            //一次读一个字符
            while(true) {
                byte[] data = new byte[1024];
                int n = inputStream.read();
                if(n == -1) {
                    break;
                }
//                System.out.println(data);
                System.out.printf("0x%x\n", n);
            }
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
